<template>
  <div>
    <el-row class="">
      <el-col :span="22">退货配件列表</el-col>
    </el-row>
    <el-divider content-position="center"></el-divider>
    <el-row>
      <data-table
        :value="tableData"
        :total-count="totalCount"
        :table-column-attributes="tableColumnAttributes"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :width="160"
      >
        <template #allNum>
          <el-col :span="8" v-if="allMount">
            <span style="line-height: 10px; text-align: left; color: #606266"
              >退货配件总金额：<span style="color: #f40; font-size: 20px"
                >￥{{ allMount }}</span
              ></span
            >
          </el-col>
          <el-col :span="8" v-if="freePriceAll">
            <span style="line-height: 10px; text-align: left; color: #606266"
              >退货配件总优惠金额：<span style="color: #f40; font-size: 20px"
                >￥{{ freePriceAll }}</span
              ></span
            >
          </el-col>
          <el-col :span="8" v-if="allMount1">
            <span style="line-height: 10px; text-align: left; color: #606266"
              >配件总数：<span style="color: #f40; font-size: 20px">{{
                allMount1
              }}</span></span
            >
          </el-col>
        </template>
      </data-table>
    </el-row>
  </div>
</template>

<script>
import { partsPage } from '@/api/after-sale/purchaseManage/purchaseReturn'
import baseMixin from '@/mixins/base'

export default {
  name: 'carInfo',
  components: {},
  props: {
    id: Number,
  },
  mixins: [
    baseMixin({
      idName: 'id',
      findData: partsPage,
      dataName: ['content', 'totalRecords'],
      format(res) {
        return res.map((data) => {
          return data
        })
      },
    }),
  ],
  data() {
    return {
      tableColumnAttributes: [
        { name: '配件编号', value: 'partsCode', type: 'text' },
        { name: '配件名称', value: 'partsName', type: 'text' },
        { name: '配件类别', value: 'partsType', type: 'text' },
        { name: '配件单位', value: 'partsUnit', type: 'text' },
        { name: '退货数量', value: 'returnNum', type: 'text' },
        { name: '退货单价', value: 'returnPrice', type: 'text' },
        { name: '总金额', value: 'amount', type: 'text' },
        { name: '优惠', value: 'freePrice', type: 'text' },
      ],
      allMount: null,
      allMount1: null,
      freePriceAll: null,
    }
  },
  methods: {},
  created() {
    this.searchOptions.inStorageId = this.id
  },
}
</script>

<style lang="scss" scoped>
.el-table .delete-row {
  background: #f5f7fa;
  color: #ccc !important;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 80px;
  height: 80px;
  display: block;
}
</style>
